//
//  CAReturnGoodsView.m
//  LNH
//
//  Created by twentylx on 2018/2/24.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CAReturnGoodsView.h"

@implementation CAReturnGoodsView

/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
}

/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    self.backgroundColor = [UIColor whiteColor];
}

/**
 初始化视图
 */
- (void)lm_createViewForView {
    [self setNeedsUpdateConstraints];
    
    [self addSubview:self.goodsImageView];
    [self addSubview:self.nameLabel];
    [self addSubview:self.sizeLabel];
    [self addSubview:self.priceLabel];
}

#pragma mark layout
- (void)updateConstraints {
    [super updateConstraints];
    
    [_goodsImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(20);
        make.top.equalTo(self).offset(20);
        make.size.mas_equalTo(CGSizeMake(100, 100));
    }];
    
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.goodsImageView.mas_right).offset(20);
        make.top.equalTo(self.goodsImageView);
        make.right.equalTo(self).offset(-20);
    }];
    
    [_sizeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel);
        make.centerY.equalTo(self.goodsImageView);
        make.right.equalTo(self).offset(-20);
    }];
    
    [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel);
        make.bottom.equalTo(self.goodsImageView);
        make.right.equalTo(self).offset(-20);
    }];
}

#pragma mark get & set
- (UIImageView *)goodsImageView {
    if (!_goodsImageView) {
        _goodsImageView = [UIImageView new];
    }
    return _goodsImageView;
}

- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [UILabel new];
        _nameLabel.numberOfLines = 3;
        _nameLabel.lineBreakMode = NSLineBreakByCharWrapping;
        _nameLabel.font = [UIFont systemFontOfSize:16];
    }
    return _nameLabel;
}

- (UILabel *)sizeLabel {
    if (!_sizeLabel) {
        _sizeLabel = [UILabel new];
        _sizeLabel.textColor = RGBCOLOR(116, 116, 116);
        _sizeLabel.font = [UIFont systemFontOfSize:14];
        _sizeLabel.numberOfLines = 2;
        _sizeLabel.lineBreakMode = NSLineBreakByCharWrapping;
    }
    return _sizeLabel;
}

- (UILabel *)priceLabel {
    if (!_priceLabel) {
        _priceLabel = [UILabel new];
        _priceLabel.textColor = RGBCOLOR(233, 85, 19);
        _priceLabel.font = [UIFont systemFontOfSize:14];
    }
    return _priceLabel;
}

@end
